﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XXVIII.DAL.Factory;
using XXVIII.DAL.IDAL;
using XXVIII.Entity;

namespace XXVIII.BLL
{
    public class FormBLL
    {

        #region 构造
        private FormBLL() { }
        private static FormBLL _instance;
        public static FormBLL Instance
        {
            get
            {
                return _instance ?? (_instance = new FormBLL());
               
            }
        }

        #endregion

        #region FormDAL 上下文
        private IFormDAL FormDAL
        {
            get
            {
                return DALFactory.CreateFormDAL();
            }
        }
        #endregion

        public bool Add(string tableName, Dictionary<string, string> keyValue)
        {
            return FormDAL.Add(tableName, keyValue);
        }

        public DataTable Get(string tableName, List<TableAndOrLikeEntity> andOrLikeList)
        {
            return FormDAL.Get(tableName, andOrLikeList);
        }

        public bool Update(string tableName, Dictionary<string, string> keyValue, List<TableAndOrLikeEntity> andOrLikeList)
        {
            return FormDAL.Update(tableName, keyValue, andOrLikeList);
        }

        public bool CreateSignTable(string tableName, List<CreateCloumnEntity> columns)
        {
            return FormDAL.CreateSignTable(tableName, columns);
        }

        public bool CheckTableExist(string tableName)
        {
            return FormDAL.CheckTableExist(tableName);
        }

        public bool DropSignTable(string tableName)
        {

            return FormDAL.DropSignTable(tableName);
        }

        public bool Delete(string tableName, List<TableAndOrLikeEntity> andOrLikeList)
        {
            return FormDAL.Delete(tableName, andOrLikeList);
        }

        public DataTable GetByPage(string tableName, List<TableAndOrLikeEntity> andOrLikeList, ref DBPageBase page)
        {
            return FormDAL.GetByPage(tableName, andOrLikeList, ref page);
        }


        public DataTable Get(string sql)
        {
            return FormDAL.Get(sql);
        }

        public bool ExecuteSql(string sql)
        {
            return FormDAL.ExecuteSql(sql);
        }

        public List<TablePropertyEntity> GetTableProperty(string tableName)
        {
            return FormDAL.GetTableProperty(tableName);
        }

        public void RecordToTable(string tableName, string customJson, bool isJoin = false)
        {
            FormDAL.RecordToTable(tableName, customJson, isJoin);
        }

        public void UnRecordToTable(string tableName)
        {
            FormDAL.UnRecordToTable(tableName);
        }

    }
}
